package com.allwees.bs.c.module.user.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.allwees.bs.core.model.user.entity.UserSignLogModel;
import com.allwees.core.common.util.DateUtil;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;

@Getter
@Setter
@TableName("usr_sign_in_log")
public class UserSignInLogEntity extends UserSignLogModel {
    private static final long serialVersionUID = -2325438009333052292L;

    @JsonIgnore
    @JSONField(serialize = false)
    public boolean isTodaySigned(){
        String signInAt = DateUtil.formatDate(this.getCreatedAt());
        String today = DateUtil.formatDate(new Date());
        return today.equals(signInAt);
    }

    @Override
    public int compareTo(UserSignLogModel bo) {
        UserSignInLogEntity entity = (UserSignInLogEntity) bo;
        return bo == null ? 1 : this.getId().compareTo(entity.getId());
    }
}
